<script setup lang="ts">
import { useControlGlobalModal } from '@renderer/layout/hooks/useControlGlobalModal'
import { useScanStore } from '@renderer/store/pinia/scan'
import { inject, computed } from 'vue'
import { BaseScanSeries, NormalScanSeries } from '@renderer/views/multiScanSeriesPage/types'
import { useRouter } from 'vue-router'
import routeConstants from '@renderer/routers/routeConstants'
import PatientInfo from '@renderer/layout/components/status/PatientInfo.vue'

const { showScanConfirmRef } = useControlGlobalModal()
const scanStore = useScanStore()
const { scanSeriesArr, activeScanSeries } = inject('multiSeries') as any

const currentSeries = computed<BaseScanSeries | NormalScanSeries | null>(() => {
  return scanStore.scanSeriesInfo.getSeriesById(activeScanSeries.id)
})

const showReconBtn = computed(() => {
  if (currentSeries.value instanceof NormalScanSeries) {
    return currentSeries.value.hasImage
  }
  return false
})
const handleConfirm = () => {
  showScanConfirmRef.value = true
  scanStore.updateScanSeries(scanSeriesArr)
}
const router = useRouter()
const handleImgProcess = () => {
  scanStore.setActiveReconSeriesId(activeScanSeries.id)
  router.push({
    name: routeConstants.ViewPage.name
  })
}
const endScan = () => {
  scanStore.$reset()
  router.push(routeConstants.PatientsPage.path)
}
</script>

<template>
  <div class="w-full h-full flex items-center px-[10px]">
    <el-button type="primary" size="large" @click="handleConfirm">执行扫描</el-button>
    <el-button v-if="showReconBtn" size="large" @click="handleImgProcess">影像处理</el-button>
    <el-button size="large" @click="endScan">结束扫描</el-button>

    <div class="w-[200px] h-full ml-auto">
      <patient-info />
    </div>
  </div>
</template>

<style scoped>

</style>
